package com.huitone.gddw.utils;

import org.apache.log4j.Logger;

import com.huitone.gddw.dao.entity.Users;

/**
 * 获取当前登录用户相关信息
 * @author wuluodan
 *
 */
public class SysLoginUtil {

	private final static Logger LOGGER = Logger.getLogger(SysLoginUtil.class);
	
	/**
	 * 获取当前登陆用户信息
	 * @return Users
	 */
	public static Users getLoginUser() {
		Users user = new Users();
		try {
			user = ResourceUtil.getSessionUser();
		} catch (Exception e) {
			LOGGER.error("查询当前用户信息出现异常：" + e.getMessage(), e);
		}
		return user;
	}
	
	/**
	 * 获取当前登陆用户ID
	 * @return 用户ID
	 */
	public static String getLoginUserId() {
		Users user = getLoginUser();
		return user == null ? "" : user.getUserId();
	}
	
	/**
	 * 判断session用户是否为管理员
	 * @return 用户ID
	 */
	public static Boolean isAdmin() {
		return ResourceUtil.isAdmin();
	}
	
}
